Namespace - LJCAddressParserLib
Parameters
currentToken - The token value.
currentIndex - The token index value.
Returns
true if the token is a Unit; otherwise, false.
Syntax
| C# |
|
public Boolean ParseUnit(String currentToken, Int32& currentIndex)
|
Parses a token into the Unit Property.
Remarks
Decrements currentIndex by one if the token is a non-range Unit.
Decrements currentIndex by two if the token is a range Unit.
The vertical bar indicates the Current Token Index.
1. Check for UnitNumber with unspecified UnitType.
If the current token starts with "#" it is a UnitNumber for an unspecified UnitType.
The UnitNumber property is set to the value following the "#" and the UnitType
property is set to "#".
|
Before: 123 Main Street North #3
UnitType = "#", UnitNumber = "3".
If the Unit values are found, then the current token index is decremented and the
Unit Parsing ends.
|
After: 123 Main Street North #3
2. Check for UnitType that does not require a UnitNumber(Range).
If the current token is a UnitType that does not require a UnitNumber(Range), then
the UnitType property is set to the current token value.
|
Before: 123 Main Street Front
UnitType = "Front", UnitNumber = null.
If the Unit values are found, then the current token index is decremented and the
Unit Parsing ends.
|
After: 123 Main Street Front
3. Check for preceding token UnitType of "#".
If the preceding token is "#" then the UnitNumber property is set to the current
token value and the UnitType property is set to "#" value.
|
Before: 123 Main Street # 3
UnitType = "#", UnitNumber = "3".
If the Unit values are found, then the current token index is decremented by 2
and the Unit Parsing ends.
|
After: 123 Main Street # 3
4. Check for preceding token UnitType.
If the preceding token is a UnitType, then the UnitType property is set to the
preceding token and the UnitNumber property is set to the current token.
|
Before: 123 Main Street Apartment 3
UnitType = "APT", UnitNumber = "3"
If the Unit values are found, then the current token index is decremented by 2.
|
After: 123 Main Street Apartment 3
Copyright © Lester J. Clark and Contributors.
Licensed under the MIT License.